package com.encryption.logic.impl;

import java.util.List;

import com.encryption.logic.ActionPermission;
import com.encryption.model.File;
import com.encryption.model.User;

public class FilePermissionSetter {
	
	private static ActionPermission permission = new ActionPermissionImpl();
	
	public static void setPermission(User user, File file){
		boolean hasView = permission.hasViewFilePermission(user, file);
		boolean hasDownload = permission.hasDownloadFilePermission(user, file);
		boolean hasPrint = permission.hasPrintFilePermission(user, file);
		boolean hasDelete = permission.hasDeleteFilePermission(user, file);
		
		file.setCanDelete(hasDelete);
		file.setCanDownload(hasDownload);
		file.setCanView(hasView);
		file.setCanPrint(hasPrint);
	}
	
	public static void setPermissionList(User user, List<File> fileList){
		for (File file : fileList){
			setPermission(user, file);
		}
	}
}
